package com.person.jc.service;

import javax.servlet.http.HttpSession;

import com.jfinal.plugin.activerecord.Db;
import com.person.jc.common.Constants;
import com.person.jc.entity.TsUser;
import com.person.jc.utils.Identities;
import com.person.jc.utils.SessionKit;

public class Service {
	
    public void setCRUD(String optMenu, String optType, String description) {
        String sql = 
            "insert into ts_crud_log\n" +
            "  (log_id, user_id, user_name,dept_id, dept_name, opt_date, opt_type, opt_menu, opt_ip, opt_detail)\n" + 
            "values\n" + 
            "  (?, ?, ?, ?, ?, now(), ?, ?, ?, ?)";
        HttpSession session = SessionKit.get();
        TsUser tsUser = (TsUser)session.getAttribute(Constants.LOGIN_USER);
        Object[] obj = new Object[9];
        obj[0] = Identities.uuid2();
        obj[1] = tsUser.getUserId();
        obj[2] = tsUser.getUserName();
        obj[3] = tsUser.getDeptId();
        obj[4] = tsUser.getDeptName();
        obj[5] = optType;
        obj[6] = optMenu;
        obj[7] = session.getAttribute(Constants.LOGIN_IP);
        obj[8] = description;
        Db.update(sql, obj);
    }
	
}
